package query

import (
	"errors"
	"ssadmin/common/query"
	"time"
)

type RoleQuery struct {
	query.Pagination `search:"-"`
	RoleId           string `form:"roleId"  search:"type:exact;column:id;table:sys_role"`
	RoleName         string `form:"roleName"  search:"type:exact;column:role_name;table:sys_role"`
	Remark           string `form:"remark"  search:"type:contains;column:remark;table:sys_role"`
	CreatorId        string `form:"-"  search:"type:exact;column:creator_id;table:sys_role"`
	Search           string `form:"search"  search:"type:contains;column:role_name;table:sys_role"`
	RoleOrder
}

type RoleOrder struct {
	CreateTime time.Time `form:"createTimeOrder"  search:"type:order;column:create_time;table:sys_role"`
	ModifyTime time.Time `form:"modifyTimeOrder"  search:"type:order;column:modify_time;table:sys_role"`
	CreatorId  string    `form:"creatorIdOrder"  search:"type:order;column:creator_id;table:sys_role"`
	Creator    string    `form:"creatorOrder"  search:"type:order;column:creator;table:sys_role"`
	Type       string    `form:"typeOrder"  search:"type:order;column:type;table:sys_role"`
}

func (m *RoleQuery) GetNeedSearch() interface{} {
	return *m
}
func (m *RoleQuery) GetId() (id interface{}, err error) {
	if len(m.RoleId) == 0 {
		return nil, errors.New("ID不能为空")
	}
	return *m, nil
}

// RoleGetReq 功能获取请求参数
type RoleGetReq struct {
	Id       string `form:"id"`
	RoleName string `form:"roleName"`
}

func (s *RoleGetReq) GetRoleId() interface{} {
	return s.Id
}
